<template>
  <AppSuperRootReturn/>

</template>
<script>

import {onMounted, provide, ref} from "vue";
import AppSuperRootReturn from "@/views/lending/App/AppSuperRootReturn.vue";
import CryptoJS from "crypto-js";

export default {
  name: "BorrowingReturnView",
  components:{AppSuperRootReturn},
  setup(){
    const cardSearchField = ref([
      {"borrowerName":"借阅人"},
      {"medicalRecord":"病案号"},
      {"hospitaLization":"住院号"},
      {"medicalRecordStatus":"病案状态"},
      {"dataPicker":"申请时间"},
    ])
    provide("cardSearchField",cardSearchField)

    //搜索框字段值控制
    const cardSearchValue = ref([
      {"medicalRecordStatus":["待归还","已归还"]}

    ])
    provide("cardSearchValue",cardSearchValue)
    //声明组件出处
    provide("LendingWhoView","BorrowingReturnView")
    const mainFormField = ref([
      {'id':'beId'},//TODO:新增
      // {'病案号':''},
      // {'住院号':''},
      // {'患者姓名':''},
      // {'借阅人':''},
      // {'借阅日期':''},
      {'归还日期':'beRestitution'},
      {'病案状态':'beMedicalRecordStatus'},
      // {'登记时间':''},
      // {'操作员':''},
      // {'借阅原因':''},
    ])
    provide("mainFormField",mainFormField)
    //病案状态的值规则控制控制
    const recordStatusValue = ref([
      {"0":'待归还'},
      {"1":'已归还'},
    ])
    provide("recordStatusValue",recordStatusValue)
    //病案状态的颜色规则控制
    const recordStatusColor = ref([
      {"待归还":'color:#0468FF'},
      {"已归还":'color:#00A76F'},
    ])
    provide("recordStatusColor",recordStatusColor)
    //rightShow:控制各组件所支持的功能规则
    const rightValue = ref([
      '查看','归还'
    ])
    provide("rightValue",rightValue)
    //rightShow:控制各组键所支持的功能展示规则
    const rightShow =ref([
      {'待归还':['查看','归还']},
      {'已归还':['查看']},
    ])
    provide("rightShow",rightShow)
    //rightColor:控制各组件所支持功能的颜色展示规则
    const rightColor = ref([
      {"查看":'color:#0468FF'},
      {"归还":'color:#0468FF'},
    ])
    provide("rightColor",rightColor)

    //密钥
    const secretKey = ref('')
    //catFieldShow:界面展示控制
    const catFieldShow = ref([
      {'targetName':'BorrowingReturnView'},
      {'title':'病案归还详情'},
      {'patientInfo':['病案号','住院号','患者姓名','性别','年龄','住院病区','入院时间','出院时间','出院诊断']},
      {'borrowInfo':['借阅','借阅日期','归还日期','超期天数','操作员','登记时间','借阅原因']},
      {'specificFunctions':['归还病案']},
      {'specificColor':[{"待归还":'color:#0468FF'},{"已归还":'color:#18CCD0'},{"归还病案":['background:#0460FF','color:#FFFFFF']},
        ]},
      {'routerGoTo':[{'返回':'/lending/borrowingReturn/home'}]}, //TODO:新增
      {'fieldMap':[
          // {'病案号':''},
          // {'住院号':''},
          // {'患者姓名':''},
          // {'借阅人':''},
          // {'借阅日期':''},
          {'归还日期':'beRestitution'},
          {'病案状态':'beMedicalRecordStatus'},
          // {'登记时间':''},
          // {'操作员':''},
          // {'借阅原因':''},
        ]
      },
      {'recordStatusValue':[
          {"0":'待归还'},
          {"1":'已归还'},
        ]},
      {'rightShow':[
          {'待归还':['归还病案']},
        ]
      }
    ])
    //catUrl:接口地址控制
    const catUrl = ref('/lending/borrowingReturn/record')
    //catControlShow:界面展示控制
    provide('catControlShow',[catUrl,secretKey,JSON.stringify(catFieldShow.value)])

    //newBrowControl：新建组件数据控制
    const newBrowControl = ref([
    ])
    //传输新建组件数据控制
    provide('newBrowControl',newBrowControl.value)


    // getSecretKey：更新秘钥规则
    function getSecretKey() {
      const currentTime = new Date().getTime();
      const baseKey = 'LendingRegisterView'; // 基础密钥
      const newSecretKey = `${baseKey}-${currentTime}`;
      secretKey.value = CryptoJS.MD5(newSecretKey).toString();
    }
    onMounted(()=>{
      // 页面加载时初始化 secretKey
      getSecretKey()
    })
    //定时更新secretKey
    setTimeout(getSecretKey, 30000)
  }

}
</script>



<style scoped>

</style>